if (window.Event) {
	document.captureEvents(Event.MOUSEMOVE);
}

document.oncontextmenu = getMouseDownRight;
document.onmousemove = getMousePosition;
document.onmousedown = getMouseDown;
document.onmouseup  = getMouseUp;
document.onload = getMousePosition;

var MOUSE = {
	x:0,
	y:0,
	clic:false,
	dbclic:false
}

function getMousePosition(event) {
	MOUSE.x = mouseX(event);
	MOUSE.y = mouseY(event);
}

function getMouseDown(event) {
	MOUSE.clic = true;
}
function getMouseUp(event) {
	MOUSE.clic = false;
}
function getMouseDownRight(event) {
	//event.preventDefault();
}

function mouseX(event) {
	if(!MAX_WIDTH) return null;
	if (event.pageX) return event.pageX - (screen.width - MAX_WIDTH)/2;
	else if (event.clientX)
	   return event.clientX + (document.documentElement.scrollLeft ?
	   document.documentElement.scrollLeft :
	   document.body.scrollLeft);
	else return null;
}

function mouseY(event) {
	if (event.pageY) return event.pageY - 20;
	else if (event.clientY)
	   return event.clientY + (document.documentElement.scrollTop ?
	   document.documentElement.scrollTop :
	   document.body.scrollTop);
	else return null;
}

function replaceMouse(){
    MOUSE.x = MAX_WIDTH/2;
    MOUSE.y = MAX_HEIGHT/2;
}
